package im.youni.horus.core;

import im.youni.horus.core.common.Constants;

import java.util.concurrent.ConcurrentHashMap;

/**
 * 指标存储
 */
public class MetricsStorge {

    static MetricsStorge metricsStorge = new MetricsStorge();

    public static MetricsStorge get() {
        return metricsStorge;
    }

    private final ConcurrentHashMap<SecondTag, String> metrics = new ConcurrentHashMap<>(Constants.maxTagNum);

    /**
     * 获取wait状态的数据集
     * 提供实时写入使用
     * @return
     */
    public synchronized ConcurrentHashMap<SecondTag, String> getReference(boolean clean) {
        if (clean) metrics.clear();
        return metrics;
    }
}
